#define _CRT_SECURE_NO_WARNINGS 1
//#include<stdio.h>
//void* my_memcpy(void* dest, const void* src, size_t num)
//{
//	void* p = dest;
//	while (num--)
//	{
//		*(char*)dest = *(char*)src;
//		(char*)dest = (char*)dest + 1;
//		(char*)src = (char*)src + 1;
//	}
//	return p;
//}
//int main()
//{
//	int i = 0;
//	int arr1[] = { 1,2,3,4,5,6,7 };
//	int arr2[] = { 8,9,7,5,2 };
//	my_memcpy(arr1, arr2, 12);
//	for (i = 0; i < 7; i++)
//	{
//		printf("%d ", arr1[i]);
//	}
//	return 0;
//}
#include<stdio.h>
#include<assert.h>
void* my_memmove(void* dest, void* src, size_t num)
{
	void* p = dest;
	if (dest < src)
	{
		while (num--)
		{
			*(char*)dest = *(char*)src;
			(char*)dest = (char*)dest + 1;
			(char*)src = (char*)src + 1;
		}
	}
	else
	{
		while (num--)
		{
			*((char*)dest + num) = *((char*)src + num);
		}
	}
	return p;
}
int main()
{
	int i = 0;
	int arr1[] = { 1,2,3,4,5,6,7 };
	int arr2[] = { 1,2,3,4,5,6,7 };
	my_memmove(arr1 + 2, arr1, 20);
	for (i = 0; i < 7; i++)
	{
		printf("%d ", arr1[i]);
	}
	printf("\n");
	my_memmove(arr2, arr2+2, 20);
	for (i = 0; i < 7; i++)
	{
		printf("%d ", arr2[i]);
	}

	return 0;
}